package com.lovo;

import com.lovo.order.dao.IOrderDao;
import com.lovo.order.dao.IUserDao;
import com.lovo.order.dto.OrderDto;
import com.lovo.order.entity.OrderEntity;
import com.lovo.order.entity.UserEntity;
import com.lovo.util.DateUtil;
import com.lovo.util.PinYinUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import java.time.LocalDate;
import java.util.Map;

@SpringBootTest(classes = com.lovo.OrderMain.class)
public class OrderT {
  @Autowired
  private IUserDao userDao;
  @Autowired
  private IOrderDao orderDao;
    @Test
    public void createOrder(){
        UserEntity user=new UserEntity();
        user.setUserName("zy");
       user=userDao.save(user);
       for(int i=0;i<20;i++) {
           OrderEntity order = new OrderEntity();
           order.setOrderData(DateUtil.getDateYYYY_MM_DD_NOW());
           order.setUser(user);
           String goodsName = "笔记本电脑,鼠标,电冰箱"+i;
           String oderNum = PinYinUtil.getPinYin(goodsName.replace(",","_")) + "_" +
                   DateUtil.getDateYYYYMMDDHHSSmmNOW() + "_" +
                   DateUtil.RandomNum(1000);
           order.setOrderNumber(oderNum);
           order.setGoodsNames(goodsName);
           order.setPriceSum(2000+i);
           orderDao.save(order);
       }
    }

}
